-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https: throw error if required params missing #3064
Conversation
https.createServer(options, function (req, res) { | ||
res.send(200); | ||
}).listen(common.PORT); | ||
}, Error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only tests cert
case. What about key
missing case? It would be better if the error messages are checked explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Adding a test case for it as well
}; | ||
|
||
assert.throws(function() { | ||
https.createServer(options, function (req, res) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this usecase, the callback passed should not be called. So, its better to use assert.fail
there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious why the callback passed should not be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kulkarniankita Because the point of the test is to throw on invalid cert
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: function(req, res) {
Marked as |
@kulkarniankita As this is your first contribution to this project, you might want to go through https://github.com/nodejs/node/blob/master/CONTRIBUTING.md and fix the commit logs :-) |
Because of my issue change, the test-https-pfx.js broke since its asserting on DEPTH_ZERO_SELF_SIGNED_CERT. Should that be fixed to not assert on it anymore and assert on my fix? |
@kulkarniankita could |
Hi @srl295 yeah adding something valid fixed the test although I am not sure of behaviour change in test-tls-no-cert-required.js as that is failing with the msg that I just added, cert is required there and not provided. There is a comment above that confuses me.
Now this comment means that whenever there is a no-authentication/no-encryption cipher then I should not be asking for a certificate or key. This makes sense so my code should have additional checking for this type of certificate but want to confirm this. (cc: @jasnell ) |
cc @nodejs/crypto |
What about ciphers without auth? like |
@indutny... Is there a concise list of known ciphers that do/don't require
|
@jasnell of course!
|
@jasnell I hope you don't suggest hard-coding this? |
No, I'm just trying to determine if there's some reasonable algorithmic way
|
So this behavior is actually the expected behavior. @indutny What about the certificate check? I think that can stay. Right? |
@thefourtheye not really |
I notice there is a getCiphers method in crypto module. Wondering if anywhere in the existing code, it checks for aNull type of check. |
@indutny oh, I wonder how the connection is encrypted and validations happen then. |
@thefourtheye it is using either ephemeral Diffie-Hellman, or not encrypting it at all. |
@kulkarniankita I think we can try iterating through ciphers and checking:
If Or, as a simpler fix! We can check if used cipher list is a default one, and throw an error like you do in this PR. This will protect users from most common errors, while keeping the Au=None ciphers work just fine for those who need them. |
lib/_tls_wrap.js
Outdated
@@ -846,10 +846,23 @@ Server.prototype.setOptions = function(options) { | |||
this.rejectUnauthorized = false; | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary newline.
@indutny Oh... I guess if server and client are not able to come to an agreement about the algorithm to be used, then they ll fall back to any of the null mechanisms. Is that correct? Apart from that, this patch is not necessary as it is trying to fix something which is actually the expected behavior right? I suppose we can close this then. @kulkarniankita thanks for the contribution. I am sorry that this patch didnt make it in. Please feel free to discuss further if needed. |
Oops sorry. Missed @indutny's suggestions. Reopening now. |
This is bad when |
4f7f022
to
f49d519
Compare
f49d519
to
fae020e
Compare
Throw an error when required parameters are missing. Handles ciphers that requires no auth. Does not throw error If pfx option is provided. Additional tests added for the same. Fixes: nodejs#3024 PR-URL: nodejs#3064
} else { | ||
this.cert = options.cert; | ||
} | ||
|
||
if (options.ca) this.ca = options.ca; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if I want to set the certificate authority for reading only but not the cert/private key.
Example: http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-client-side-ssl-authentication.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbshakumar you mean if cert authority is provided then skip this whole cert/key error handling right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kulkarniankita It has been a while since I've looked at this. Should it be possible to set the certificate authority and not set a cert?
7da4fd4
to
c7066fb
Compare
c133999
to
83c7a88
Compare
Given the lack of forward progress and the uncertainty of what the actual behavior should be, I'm closing. This can be reopened if necessary |
throw Error when required parameters for options in https.createServer are missing
The required parameters of https.createServer is key and cert. When these parameters are not provided by the user then a new Error is thrown for the missing parameter.
A subsequent test is also added to verify the same.
This was discussed in Issue: #3024
cc: @jasnell @mhdawson